//
// Created by harrybao on 2019/4/9.
//

#include "object_pool_manager.h"

bool ObjectPoolManager::Init()
{
    return true;
}

void ObjectPoolManager::UnInit()
{
    for (auto &iter: pools_)
    {
        delete iter.second;
    }
    pools_.clear();
}

ObjectPoolManager::ObjectPoolManager()
{
}

ObjectPoolManager::~ObjectPoolManager()
{
    UnInit();
}

void ObjectPoolManager::Register(size_t hash_code, AbstractPool *pool)
{
    pools_.emplace(hash_code, pool);
}

void ObjectPoolManager::Recycle(size_t hash_code, void* data)
{
    auto it = pools_.find(hash_code);
    if (it != pools_.end())
    {
        it->second->Recycle(data);
    }
}

